<?php

include_once("./Db_pdo.class.php");
require('./sql/s.php');//引入类 
set_time_limit(0);
ini_set('date.timezone','Asia/Shanghai');
$DB=new Db_pdo("cxh_v3","cxhv3","cxhv3pwd!@#"); 
echo '<pre>';
$sql = "SELECT
a.aplc_car_no,
a.aplc_car_vin,
b.realname,
b.cxhname,
b.mobile,
c.uex_parentList

FROM
ims_cxh_apply_subsidy_car AS a
INNER JOIN ims_ewei_shop_member AS b ON b.id = a.member_id
INNER JOIN ims_cxh_user_ex AS c ON c.member_id = b.id
WHERE
a.aplc_status = 1
AND a.is_all_back = 1
AND a.is_month_back = 1
AND a.month_now = 201812 order by c.uex_areaName";
// $data= $DB->new_query($sql);
// $data = $data->fetchAll(PDO::FETCH_ASSOC);  
// $newarr =array();

// foreach($data as $key =>$v){
//     $newarr = explode(',',$v['uex_parentList']);
//     array_pop($newarr);
//     array_pop($newarr);
//     krsort($newarr);
//     array_pop($newarr);
//     // print_r($newarr);
//     foreach($newarr as $k =>$value){
//         $sql1  = "SELECT a.mobile,a.cxhname as fcxhname,a.realname as newrealname,c.uex_areaName,c.uex_cityNname,
//         c.uex_provinceName  FROM ims_ewei_shop_member as a 
//         INNER JOIN ims_cxh_user_ex AS c ON c.member_id = a.id
//         WHERE a.id = ".$value." and a.cxhname like 'DLS%'";
//         $fdate = $DB->new_query($sql1);
//         $fdate = $fdate->fetchAll(PDO::FETCH_ASSOC); 
//         if($fdate){
//             $data[$key]['newmobile'] = $fdate['0']['mobile'];
//             $data[$key]['newcxhname'] = $fdate['0']['fcxhname'];
//             $data[$key]['newrealname'] = $fdate['0']['newrealname'];
//             $data[$key]['uex_areaName'] = $fdate['0']['uex_areaName'];
//             $data[$key]['uex_cityNname'] = $fdate['0']['uex_cityNname'];
//             $data[$key]['uex_provinceName'] = $fdate['0']['uex_provinceName'];
//             break;
//         }
//     }
   
// }
// $model = new digui();

// $data  = $model->sortArray($data,'uex_areaName',SORT_ASC);


// file_put_contents('shcar.txt',serialize($data));



// $data = unserialize(file_get_contents('shcar.txt'));
// //  print_r($data);
// $arr = array_chunk($data, 20000);
// foreach($arr as $v) {
   

//     $sql = "INSERT INTO ceshi (`aplc_car_no`,`aplc_car_vin`,`realname`,`cxhname`,`mobile`
//     ,`newmobile`,`newcxhname`,`newrealname`,`uex_provinceName`,`uex_cityNname`,`uex_areaName`) VALUES ";
   
   
// 	foreach ($v as $value) { 
//         if(empty($value['newmobile'])){
//             $value['newmobile'] ='';
//         }

        
//         if($value['newmobile']<0){
//             $value['newmobile'] ='';
//         }

//         if(empty($value['newcxhname'])){
//             $value['newcxhname'] ='';
//         }
//         if(!$value['newcxhname']){
//             $value['newcxhname'] ='';
//         }
//         if(empty($value['uex_areaName'])){
//             $value['uex_areaName'] ='';
//         }
//         if(empty($value['uex_cityNname'])){
//             $value['uex_cityNname'] ='';
//         }
//         if(empty($value['uex_provinceName'])){
//             $value['uex_provinceName'] ='';
//         }
// 		$param['aplc_car_no'] = $value['aplc_car_no'];
// 		$param['aplc_car_vin'] =$value['aplc_car_vin'];
// 		$param['realname'] = $value['realname'];
// 		$param['cxhname'] =$value['cxhname'];
// 		$param['mobile'] =$value['mobile'];
// 		$param['newmobile'] = $value['newmobile'];
//         $param['newcxhname'] = $value['newcxhname'];
//         $param['newrealname'] = $value['newrealname'];
//         $param['uex_provinceName'] = $value['uex_provinceName'];
//         $param['uex_cityNname'] = $value['uex_cityNname'];
//         $param['uex_areaName'] = $value['uex_areaName'];
        
// 	    $values="('".implode("','",array_values($param))."'),";
// 	    // echo $values;
// 	    $sql .= $values;
//     }
    
//     $sql = rtrim($sql, ",");
// 	$DB->db->query($sql);
// 	// return ;
// }
// echo $sql;
// print_r($data);
?>